#include "header.h"

grid::grid(int xsinit, int ysinit, int vlinit, int hlinit, int xinit, int yinit) 
{
  xsquares = xsinit;
  ysquares = ysinit;
  vlen = vlinit;
  hlen = hlinit;
  x = xinit;
  y = yinit;
}

int grid::getXsquares(void) 
{
    return xsquares;
}

int grid::getYsquares(void) 
{
    return ysquares;
}

int grid::getVlen(void) 
{
    return vlen;
}

int grid::getHlen(void) 
{
    return hlen;
}

int grid::draw(void) 
{
  return draw_rect_grid(xsquares, ysquares, hlen, vlen, x, y, makecol(255,255,255));
}

int grid::grid_square_coord(int xgrid, int ygrid, char which) 
{
  if (!(which == 'x' || which == 'y')) return -1;
  int xpix = (x - ((xsquares * hlen)/2)) + (xgrid * hlen) - (hlen/2);
  int ypix = (y - ((ysquares * vlen)/2)) + (ygrid * vlen) - (vlen/2);
  if (which == 'x') return xpix;
  else return ypix;
}
